package com.future.order;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.MessageSource;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.LocaleResolver;

import java.util.Locale;

@EnableFeignClients // 开启Feign远程调用功能
@EnableDiscoveryClient
@SpringBootApplication
//@Import({AnnotationAutoConfig.class, MyLogAspect.class})
public class OrderMain8000Application {
    public static void main(String[] args) {
        SpringApplication.run(OrderMain8000Application.class, args);
    }

    @Autowired
    private MessageSource messageSource;

    @Autowired
    private LocaleResolver localeResolver;

    @GetMapping("/")
    public String home(HttpServletRequest request, Model model) {
        Locale locale = localeResolver.resolveLocale(request);

        model.addAttribute("homeMenu", messageSource.getMessage("menu.home", null, locale));
        model.addAttribute("aboutMenu", messageSource.getMessage("menu.about", null, locale));
        model.addAttribute("contactMenu", messageSource.getMessage("menu.contact", null, locale));

        return "home";
    }
}